<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>糖半甜</title>
    <link rel="stylesheet" href="__TMPL__/public/shop/css/update.css">
    <script src="__TMPL__/public/shop/js/jquery.js"></script>
    <script src="__STATIC__/js/layer/layer.js"></script>
    <script src="__TMPL__/public/shop/js/update.js"></script>
    <style>
        .alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6;}
        .tan-a{
            text-decoration: none;
            background-color: #f37b1d;
            display: block;
            float: left;
            text-align: center;
            border-radius: 10px;
            color: #fff;
            font-size: 20px;
            font-weight: 800;
            margin: 1%;
            padding: 1%;
        }
    </style>
</head>
<body onload="javascript:return require();">
<div class="alert"></div>
<div>
<table class="table table-bordered">
    <thead>
    <input type="hidden" id="goodsid" value="{$data.goodsid}">
    <input type="hidden" id="detail_id" value="{$data.detail_id}">
    <foreach name="status" item="status">
        <a class="am-btn am-btn-warning am-radius am-margin-right-sm nature tan-a state" href="#"><input type="hidden" value="{$status.id}">{$status.state_name}</a>
    </foreach>
    </thead>
</table>
</div>
</body>
<script>
   $('.state').click(function(){
       var id=$(this).children().val();
       var index = parent.layer.getFrameIndex(window.name);
       var orderid = parent.$('#orderid').val();
       var goodsid=$('#goodsid').val();
       var detail_id=$('#detail_id').val();
       $.post("{:url('menu/goods_state')}",{id:id,orderid:orderid,goodsid:goodsid,detail_id:detail_id},function(date){
             if(date.msg.data != null)
             {
                 parent.$('.orderid').html(orderid + '<input type="hidden" id="orderid" value="' + orderid + '">');
                 var data = date.msg.data;
                 var src = '';
                 var pay = date.msg.pay;
                 parent.$('.num').html(pay.num);
                 parent.$('.all').html(pay.all_money);
                 parent.$('#vip').val(pay.vip);
                 parent.$('.orderid').html('<input class="am-text-right" type="text" value="'+pay.orderid+'" style="background: transparent;border:none;">'+'<input type="hidden" id="orderid" value="' + pay.orderid + '">');
                 $.each(data, function (k, val) {
                     var k=k+1;
                     src += '<dl class="am-padding-top-xs am-padding-bottom-xs am-padding-left-sm ">' +
                         '<dt class="dt-h font-z">' +
                         k+
                         val.g_goodsname + '(' + val.format + ')' +
                         '</dt>'+
                         '<div class="am-input-group am-fr">'+
                         '<span class="am-input-group-label minus" onclick="javascript:minus(this)">-'+
                         '</span>'+
                         '<input type="hidden"  class="am-form-field detail_id" value="'+
                         val.id+
                         '">'+
                         '<input type="hidden"  class="am-form-field stemeals" value="'+
                         val.stemeal+
                         '">'+
                         '<input type="hidden"  class="am-form-field nature" value="'+
                         val.nature+
                         '">'+
                         '<input type="text" readonly="readonly" class="am-form-field" value="'+
                         val.count+
                         '">'+
                         '<span class="am-input-group-label add" onclick="javascript:add(this)">+'+
                         '</span>'+
                         '</div>'+
                         '<input type="hidden"  class="am-form-field ordid" value="'+
                         val.orderid+
                         '">'+
                         '<dd>'+
                         '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ">'+
                         '<input type="hidden"  class="am-form-field detail_id" value="'+
                         val.id+
                         '">'+
                         '<div class="am-link-muted am-text-xs font-z">单价：￥'+
                         val.money +
                         '</div>'+
                         '<div class="am-text-danger am-text-xs font-z ">小计：￥<span class="ipt1" style="display: inline;cursor:pointer;color:green;">'+
                         val.total +'</span>'+
                         '<input class="ipt2" style="display:none;width:100%;border:1px solid red;width:40px;" maxlength="10"/><input class="ipt3" type="hidden" value="'+val.total+'"/>'+
                         '</div>'+
                         '</div>'+
                         '<div class="am-u-md-6 am-u-lg-6 am-padding-right-0">'+
                         '</div>'+
                         '<div class="clear"></div>'+
                         '<div class="am-u-md-6 am-u-lg-6 am-padding-left-0 left-w ss">'+
                         '<div class="flo-l font-z wendu">'+
                         '<input type="hidden"  class="am-form-field detail_id" value="'+
                         val.id+
                         '">'+
                         '<input type="hidden"  class="am-form-field goodid" value="'+
                         val.goodsid+
                         '">'+
                         '<a class="am-btn am-btn-warning am-radius am-margin-right-sm nature" herf="#">口味('+
                         val.naturename+
                         ')</a>'+
                         '<a class="am-btn am-btn-warning am-radius am-margin-right-sm edit" herf="#">改价'+
                         '</a>'+
                         '</div>'+
                         '</div>'+
                         '</dd>' +
                         '</dl>'
                     parent.$('#cart').html(src);
                 });
                 parent.layer.close(index); //执行关闭
             }else{
                 alert('添加失败');
             }
       })
   })
</script>
</html>
